package com.zhp.farmerclient.controller;

import com.zhp.farmerclient.common.Result;
import com.zhp.farmerclient.mapper.CommentMapper;
import com.zhp.farmerclient.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/comment")
public class CommentController {
    @Autowired
    public CommentService commentService;

    //分页显示（查询）
    @GetMapping("/page")
    public Result findPage(@RequestParam Integer pageNum,
                           @RequestParam Integer pageSize,
                           @RequestParam(defaultValue = "") String post_id,
                           @RequestParam(defaultValue = "") String content,
                           @RequestParam(defaultValue = "") String user_id) {
        return commentService.page(pageNum,pageSize,post_id,content,user_id);
    }

    //删除
    @DeleteMapping("/{id}")
    public Result delete(@PathVariable Integer id) {
        return commentService.delete(id);
    }
    //批量删除
    @PostMapping("/del/batch")
    public Result deleteBatch(@RequestBody List<Integer> ids) { // [1,2,3]
        return commentService.deletes(ids);
    }
}
